<?php

namespace app\admin\controller\visit;

use app\admin\model\AuthGroup;
use app\admin\model\AuthGroupAccess;
use app\admin\model\Users;
use app\admin\model\visit\Visiting;
use app\common\controller\Backend;
use think\Db;

/**
 *
 *
 * @icon fa fa-circle-o
 */
class People extends Backend
{

    /**
     * Visiting模型对象
     * @var \app\admin\model\yuyurVisiting
     */
    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->name =Users::field("name,id")->select();
        $groupId = AuthGroup::where('name','讲解员')
            ->value('id');
        $authGroupList = AuthGroupAccess::where('group_id',$groupId)
            ->column('uid');
        $speak = DB::table('fa_admin')->whereIn('id',implode(',',$authGroupList))->column('id,nickname');
        $this->view->assign("speak", $speak); //讲解员
    }

    /**
     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
     */



    /**
     * 查看
     */
    public function index()
    {
        if ($this->request->isAjax())
        {
            $data = input("get.");
//            dd($data);
            $l = Visiting::whereIn('id',$data['id'])
                ->where('type','=',1)
                ->setField('admin_id',$data['tiaojie']);
//            dd($l);
//            Visiting::where([["id","in",$data['id'],['type','=',1]]])->update(['admin_id'=>$data['tiaojie']]);
//            dd($data);
            return info('成功！', 1,'',"");
        }

            $data = input("get.");
            $data = json_decode($data['code'],1);
            foreach($data as $k=>$val){
                $id[]=$val['id'];
            }
            $id  = implode(",",$id);
            $this->assign("id",$id);
           return $this->view->fetch();
    }


}
